package io.renren.modules.avanotes.service;

import io.renren.common.utils.BizUtils;
import io.renren.modules.avanotes.entity.ReviewScheduleEntity;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: xiaomi
 * @date: 2022/2/27
 * @description: 根据艾宾浩斯记忆曲线 自动生成对应的复习
 */
public interface EbbinghausReviewStrategy {

    /**
     * 生成复习数组
     * @return
     */
    int[] getReviewArr();

    default List<ReviewScheduleEntity> genReviewSchedules(Long studyId, Integer ssId, Integer studyDate, Long userId){
        List<ReviewScheduleEntity> list = new ArrayList<>();
        int year = studyDate / 10000;
        LocalDate localDate = BizUtils.genLocalDateByIntDate(studyDate, year);
        int[] arr = getReviewArr();
        int internal = 0;
        int len = arr.length;
        for (int i = 0; i < len; i++) {
            internal += arr[i];
            //添加6次
            String tempDate = localDate.plusDays(internal).toString().replaceAll("-", "");
            list.add(new ReviewScheduleEntity(studyId, ssId, userId, Integer.parseInt(tempDate)));
        }
        return list;
    }

}
